<template>
  <div class="invoice-item">
    <div>
      <div class="title">惠州市熊猫不走蛋糕烘焙有限公司</div>

      <div class="content">
        <div class="fields">
          <div v-for="(item, index) in fields" :key="index" class="field-item">
            <span class="field-label fz-12">{{item.label}}</span>
            <span class="fz-12">{{invoiceItem[item.key]}}</span>
          </div>

          <div class="field-item" v-show="(invoiceItem.status == 2 || invoiceItem.status == 4)">
            <span class="field-label fz-12">未通过原因：</span>
            <span class="fz-12" v-show="(invoiceItem.status == 2)">{{ invoiceItem['serviceRemark'] }}</span>
            <span class="fz-12" v-show="(invoiceItem.status == 4)">{{ invoiceItem['remarks'] }}</span>
          </div>
        </div>
      </div>
    </div>

    <div class="status" v-if="statusMap[invoiceItem.status]" :class="statusMap[invoiceItem.status].status">
      <div class="status-text">
        {{statusMap[invoiceItem.status].label}}
      </div>
    </div>
  </div>
</template>

<script>
const fields = [{
  label: '订单号：',
  key: 'xmbzNo',
},{
  label: '抬头：',
  key: 'invoiceTitle',
},{
  label: '税号：',
  key: 'invoiceNo',
},{
  label: '手机号：',
  key: 'phone',
}]
const statusMap = {
  0: {
    label: '开票中',
    status: 'invoicing'
  },
  1: {
    label: '开票中',
    status: 'invoicing'
  },
  3: {
    label: '已开票',
    status: 'invoiced'
  },
  2: {
    label: '未通过',
    status: 'fail'
  },
  4: {
    label: '未通过',
    status: 'fail'
  },
}
export default {
  props: {
    invoiceItem: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      fields,
      statusMap
    };
  },
};
</script>
<style lang="scss" scoped>
.invoice-item {
  background: #fdeded;
  border-radius: 5px;
  margin-bottom: 12px;
  padding: 8px;
  overflow: hidden;
  position: relative;
  .title {
    font-size: 14px;
    font-weight: bold;
  }

  .content {
    margin-top: 4px;
    
    .fields {
      .field-item {
        line-height: 18px;
        font-size: 12px;
        .field-label {
          display: inline-block;
          width: 80px;
          text-align: right;
        }
      }
    }
  }
  .status {
    width: 60px;
    height: 60px;
    border: 2px solid #4187f8;
    border-radius: 50%;
    display: flex;
    color: #4187f8;
    align-items: center;
    justify-content: center;
    transform: rotate(-30deg);
    position: absolute;
    top: -8px;
    right: -8px;
    &.invoicing {
      color: #4187f8;
      border-color: #4187f8;
    }
    &.invoiced {
      color: #37c062;
      border-color: #37c062;
    }
    &.fail {
      color: #e4272c;
      border-color: #e4272c;
    }
    .status-text {
      font-weight: bold;
      font-size: 12px;
      width: 50px;
      height: 50px;
      border: 2px solid;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
</style>